home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 4
/
Apprentice-Release4.iso
/
Languages
/
PowerMacOberon 1.2
/
Dialogs
/
MyUI.Mod
(
.txt
)
< prev
next >
Wrap
Oberon Text
|
1995-07-10
|
46KB
|
1,084 lines
Syntax10.Scn.Fnt
InfoElems
Alloc
Syntax10.Scn.Fnt
StampElems
Alloc
10 Jul 95
"Title": MyUI
"Author": Christoph Steindl (CS)
"Abstract": MyUI provides a user interface for the compile commands such as Compiler.Compile
and Folds.Compile, for Edit.Get and Edit.Set, for Edit.Print and for Edit.Search, Edit.Replace,
Edit.ReplaceAll and Edit.ClearReplaceBuffer
"Keywords": user interface, Compiler.Compile, Folds.Compile, Edit.Get, Edit.Set, Edit.Print,
Edit.Search, Edit.Replace, Edit.ReplaceAll, Edit.ClearReplaceBuffer
"Version": 1
"From": 20.12.94 14:01:53
"Until":
"Changes": no changes
"Hints":
Dialog.Open Insert.Dlg
Dialog.Edit Compiler.Dlg
Dialog.Open Compiler.Dlg
Dialog.Edit GetSet.Dlg
Dialog.Open GetSet.Dlg
Dialog.Edit Print.Dlg
Dialog.Open Print.Dlg
Dialog.Edit Search.Dlg
Dialog.Open Search.Dlg
Syntax10i.Scn.Fnt
StampElems
Alloc
10 Jul 95
Syntax10b.Scn.Fnt
ParcElems
Alloc
FoldElems
Syntax10.Scn.Fnt
Syntax10b.Scn.Fnt
CONST
OptionChar* = "/";
PrintOptionsFile* = "PrintOptions";
eps = 1.0D-9; eps0 = 0.5D-9;
Syntax10.Scn.Fnt
FoldElems
StyleElem = POINTER TO StyleElemDesc;
StyleElemDesc = RECORD
styleElem: StyleElems.Parc;
next: StyleElem
END;
Operation = ARRAY 10 OF CHAR;
Var = POINTER TO VarDesc;
VarDesc = RECORD
name: ARRAY 32 OF CHAR;
value: LONGREAL;
next: Var
END;
Syntax10.Scn.Fnt
vwr: Viewers.Viewer; selbeg, selend: TextFrames.Location; (* for StoreSelection and RestoreSelection *)
styleElems: StyleElem;
p: Dialogs.Panel; o: Dialogs.Object;
command: ARRAY 32 OF CHAR; par: Oberon.ParList;
oldLog, newLog: Texts.Text;
w: Texts.Writer;
res-: INTEGER;
doSearch: BOOLEAN;
oldValue, value: LONGREAL; (* global variables for Calc.Dlg *)
commaPos: LONGREAL; (* <= 1 if a comma has been entered (i.e. right of comma) *)
oldOp, op: Operation;
newNumber: BOOLEAN;
vars: Var;
Syntax10.Scn.Fnt
common procedures
Syntax10.Scn.Fnt
FoldElems
Syntax10b.Scn.Fnt
PROCEDURE Comp;
VAR
t: Texts.Text;
opt: ARRAY 20 OF CHAR; res: INTEGER; beg, end, time: LONGINT;
findPC: BOOLEAN; i, j: INTEGER;
PROCEDURE Do;
VAR ch: CHAR; error: BOOLEAN; fbeg, fend, ftime, breakpc: LONGINT;
scanner, fs: Texts.Scanner; sourceR: Texts.Reader; line: INTEGER; ft: Texts.Text; fw: Texts.Writer;
BEGIN
error := FALSE;
Texts.OpenScanner(scanner, t, beg); Texts.Scan(scanner);
WHILE (scanner.class IN {Texts.Name, Texts.String}) & (Texts.Pos(scanner) - scanner.len <= end) & ~error DO
Texts.OpenWriter(w);
Texts.WriteString(w, scanner.s);
line := scanner.line; opt[j] := 0X; i := j;
Texts.Scan(scanner);
IF (scanner.line = line) & (scanner.class = Texts.Char) & (scanner.c = OptionChar) THEN
ch := scanner.nextCh;
WHILE ((ch >= "0") & (ch <= "9") OR (ch >= "a") & (ch <= "z")) & (i < LEN(opt) - 1) DO
opt[i] := ch; INC(i);
IF ch = "f" THEN findPC := ~findPC END;
Texts.Read(scanner, ch)
END ;
scanner.nextCh := ch;
Texts.Scan(scanner)
END;
opt[i] := 0X;
par.frame := Oberon.Par.frame; par.vwr := Oberon.Par.vwr;
IF findPC THEN
LOOP
Oberon.GetSelection(ft, fbeg, fend, ftime);
IF ftime >= 0 THEN
Texts.OpenScanner(fs, ft, fbeg); Texts.Scan(fs);
IF fs.class = Texts.Int THEN breakpc := fs.i; EXIT END
END;
Texts.WriteString(fw, " pc not selected"); Texts.WriteLn(fw);
Texts.Append(Oberon.Log, fw.buf); error := TRUE; RETURN
END;
Texts.OpenReader(sourceR, t, beg);
Compiler.Module(sourceR, opt, breakpc, Oberon.Log, error);
ELSE
Texts.Write(w, OptionChar); Texts.WriteString(w, opt);
Texts.Append(par.text, w.buf); Oberon.Call(command, par, FALSE, res)
END
END
END Do;
BEGIN
InitPar; i := 0;
IF On ("idx") THEN opt[i] := "x"; INC(i) END; IF On ("type") THEN opt[i] := "t"; INC(i) END;
IF On ("nil") THEN opt[i] := "n"; INC(i) END; IF On ("init") THEN opt[i] := "p"; INC(i) END;
IF On ("assert") THEN opt[i] := "s"; INC(i) END;
IF On ("pc") THEN findPC := TRUE; opt[i] := "f"; INC(i) ELSE findPC := FALSE END;
opt[i] := 0X; j := i;
IF On ("mrs") THEN
Oberon.GetSelection(t, beg, end, time);
IF findPC THEN
o := p.NamedObject("tpc"); t := o(DialogTexts.Item).GetText(); o(DialogTexts.Item).SetSelection(0, t.len)
END;
IF time >= 0 THEN Do END
END;
IF findPC THEN
o := p.NamedObject("tpc"); t := o(DialogTexts.Item).GetText(); o(DialogTexts.Item).SetSelection(0, t.len)
END;
IF On ("marked") THEN
Texts.Write(w, "*"); Texts.Write(w, OptionChar); Texts.WriteString(w, opt);
Texts.Append(par.text, w.buf); par.vwr := Oberon.MarkedViewer();
IF (par.vwr # NIL) & (par.vwr.dsc # NIL) & (par.vwr.dsc.next IS TextFrames.Frame) THEN
par.frame := par.vwr.dsc.next(TextFrames.Frame)
ELSE
par.frame := NIL
END;
Oberon.Call(command, par, FALSE, res)
END;
IF On ("list") THEN
o := p.NamedObject("files"); t := o(DialogTexts.Item).GetText();
IF t.len > 0 THEN beg := 0; end := t.len; Do END
END;
IF findPC THEN o := p.NamedObject("tpc"); o(DialogTexts.Item).RemoveSelection END
END Comp;
PROCEDURE Compile*;
BEGIN command := "Compiler.Compile"; Comp
END Compile;
PROCEDURE FoldsCompile*;
BEGIN command := "Folds.Compile"; Comp
END FoldsCompile;
Syntax10.Scn.Fnt
Commands for the dialogue GetSet.Dlg
Syntax10.Scn.Fnt
Syntax10b.Scn.Fnt
FoldElems
Syntax10.Scn.Fnt
FoldElems
Syntax10.Scn.Fnt
VAR t: Texts.Text;
BEGIN
t := o(DialogTexts.Item).GetText(); Texts.Delete(t, 0, t.len);
Texts.WriteInt(w, l, 0); Texts.Append(t, w.buf)
END WriteNumber;
Syntax10.Scn.Fnt
VAR t: Texts.Text; i: INTEGER;
BEGIN
t := o(DialogTexts.Item).GetText(); Texts.Delete(t, 0, t.len);
i := 0;
WHILE s[i] # 0X DO Texts.Write(w, s[i]); INC(i) END;
Texts.Append (t, w.buf)
END WriteName;
VAR o: Dialogs.Object;
PROCEDURE WriteNumber(o: Dialogs.Object; l: LONGINT);
PROCEDURE WriteName(o: Dialogs.Object; s: ARRAY OF CHAR);
BEGIN
p := Dialogs.cmdPanel;
ChangeValue ("alternate", FALSE); ChangeValue ("nopagenr", FALSE);
ChangeValue ("nopagenr1", FALSE); ChangeValue ("Romannum", FALSE);
ChangeValue ("draft", FALSE);
o := p.NamedObject("tfirstpage"); WriteNumber(o, 0);
o := p.NamedObject("tfirstpage"); WriteNumber(o, 0);
o := p.NamedObject("copies"); WriteNumber(o, 1);
o := p.NamedObject("font"); WriteName(o, "");
ChangeValue ("nohdr", FALSE); ChangeValue ("defhdr", TRUE);
ChangeValue ("header", FALSE); ChangeValue ("custom1", FALSE);
o := p.NamedObject("thdr"); WriteName(o, "");
ChangeValue ("default1", TRUE); ChangeValue ("custom2", FALSE);
o := p.NamedObject("postxtleft"); WriteNumber(o, 150);
o := p.NamedObject("postxtbottom"); WriteNumber(o, 150);
o := p.NamedObject("txtwidth"); WriteNumber(o, 1650);
o := p.NamedObject("txtheight"); WriteNumber(o, 2600);
o := p.NamedObject("poshdrleft"); WriteNumber(o, 150);
o := p.NamedObject("poshdrbottom"); WriteNumber(o, 2800);
o := p.NamedObject("hdrwidth"); WriteNumber(o, 1650);
ChangeValue ("default2", TRUE); ChangeValue ("fromto", FALSE); ChangeValue ("all", TRUE);
o := p.NamedObject("from"); WriteNumber(o, 0);
o := p.NamedObject("to"); WriteName(o, "");
END SetDefaultOptions;
Syntax10.Scn.Fnt
FoldElems
VAR r: Files.Rider; f: Files.File; b: BOOLEAN; o: Dialogs.Object;
PROCEDURE WriteNumber(o: Dialogs.Object);
VAR t: Texts.Text; l: LONGINT;
BEGIN
Files.ReadLInt(r, l);
t := o(DialogTexts.Item).GetText(); Texts.Delete(t, 0, t.len);
Texts.WriteInt(w, l, 0); Texts.Append(t, w.buf)
END WriteNumber;
PROCEDURE WriteName(o: Dialogs.Object);
VAR t: Texts.Text; ch: CHAR;
BEGIN
t := o(DialogTexts.Item).GetText(); Texts.Delete(t, 0, t.len);
Files.Read(r, ch);
WHILE ch # 0X DO Texts.Write(w, ch); Files.Read(r, ch) END;
Texts.Append(t, w.buf)
END WriteName;
BEGIN
f := Files.Old(PrintOptionsFile);
IF f # NIL THEN
p := Dialogs.cmdPanel; Files.Set(r, f, 0);
Files.ReadBool (r, b); ChangeValue ("alternate", b); Files.ReadBool (r, b); ChangeValue ("nopagenr", b);
Files.ReadBool (r, b); ChangeValue ("nopagenr1", b); Files.ReadBool (r, b); ChangeValue ("Romanum", b);
Files.ReadBool (r, b); ChangeValue ("draft", b);
o := p.NamedObject("tfirstpage"); WriteNumber(o); o := p.NamedObject("copies"); WriteNumber(o);
o := p.NamedObject("font"); WriteName(o);
Files.ReadBool (r, b); ChangeValue ("nohdr", b); Files.ReadBool (r, b); ChangeValue ("defhdr", b);
Files.ReadBool (r, b); ChangeValue ("header", b);
o := p.NamedObject("thdr"); WriteName(o);
Files.ReadBool (r, b); ChangeValue ("custom1", b); Files.ReadBool (r, b); ChangeValue ("default1", b);
o := p.NamedObject("postxtleft"); WriteNumber(o); o := p.NamedObject("postxtbottom"); WriteNumber(o);
o := p.NamedObject("txtwidth"); WriteNumber(o); o := p.NamedObject("txtheight"); WriteNumber(o);
Files.ReadBool (r, b); ChangeValue ("custom2", b); Files.ReadBool (r, b); ChangeValue ("default2", b);
o := p.NamedObject("poshdrleft"); WriteNumber(o); o := p.NamedObject("poshdrbottom"); WriteNumber(o);
o := p.NamedObject("hdrwidth"); WriteNumber(o);
Files.ReadBool (r, b); ChangeValue ("fromto", b); Files.ReadBool (r, b); ChangeValue ("all", b);
o := p.NamedObject("from"); WriteNumber(o); o := p.NamedObject("to"); WriteNumber(o)
ELSE SetDefaultOptions END;
END InitPrintDlg;
Syntax10.Scn.Fnt
FoldElems
VAR r: Files.Rider; f: Files.File;
PROCEDURE WriteNumber(o: Dialogs.Object);
VAR s: Texts.Scanner; t: Texts.Text; l: LONGINT;
BEGIN
t := o(DialogTexts.Item).GetText(); l := 0;
IF t.len > 0 THEN
Texts.OpenScanner(s, t, 0); Texts.Scan(s); IF s.class = Texts.Int THEN l := s.i END
END;
Files.WriteLInt(r, l)
END WriteNumber;
PROCEDURE WriteName(o: Dialogs.Object);
VAR rt: Texts.Reader; t: Texts.Text; ch: CHAR;
BEGIN
t := o(DialogTexts.Item).GetText();
Texts.OpenReader(rt, t, 0); Texts.Read(rt, ch);
WHILE ~rt.eot DO Files.Write(r, ch); Texts.Read(rt, ch) END;
Files.Write(r, 0X)
END WriteName;
BEGIN
f := Files.New(PrintOptionsFile); Files.Set(r, f, 0);
p := Dialogs.cmdPanel;
o := p.NamedObject("alternate"); Files.WriteBool(r, o(DialogCheckBoxes.Item).on);
o := p.NamedObject("nopagenr"); Files.WriteBool(r, o(DialogCheckBoxes.Item).on);
o := p.NamedObject("nopagenr1"); Files.WriteBool(r, o(DialogCheckBoxes.Item).on);
o := p.NamedObject("Romannum"); Files.WriteBool(r, o(DialogCheckBoxes.Item).on);
o := p.NamedObject("draft"); Files.WriteBool(r, o(DialogCheckBoxes.Item).on);
o := p.NamedObject("tfirstpage"); WriteNumber(o);
o := p.NamedObject("copies"); WriteNumber(o);
o := p.NamedObject("font"); WriteName(o);
o := p.NamedObject("nohdr"); Files.WriteBool(r, o(DialogRadioButtons.Item).on);
o := p.NamedObject("defhdr"); Files.WriteBool(r, o(DialogRadioButtons.Item).on);
o := p.NamedObject("header"); Files.WriteBool(r, o(DialogRadioButtons.Item).on);
o := p.NamedObject("thdr"); WriteName(o);
o := p.NamedObject("custom1"); Files.WriteBool(r, o(DialogRadioButtons.Item).on);
o := p.NamedObject("default1"); Files.WriteBool(r, o(DialogRadioButtons.Item).on);
o := p.NamedObject("postxtleft"); WriteNumber(o);
o := p.NamedObject("postxtbottom"); WriteNumber(o);
o := p.NamedObject("txtwidth"); WriteNumber(o);
o := p.NamedObject("txtheight"); WriteNumber(o);
o := p.NamedObject("custom2"); Files.WriteBool(r, o(DialogRadioButtons.Item).on);
o := p.NamedObject("default2"); Files.WriteBool(r, o(DialogRadioButtons.Item).on);
o := p.NamedObject("poshdrleft"); WriteNumber(o);
o := p.NamedObject("poshdrbottom"); WriteNumber(o);
o := p.NamedObject("hdrwidth"); WriteNumber(o);
o := p.NamedObject("fromto"); Files.WriteBool(r, o(DialogRadioButtons.Item).on);
o := p.NamedObject("all"); Files.WriteBool(r, o(DialogRadioButtons.Item).on);
o := p.NamedObject("from"); WriteNumber(o);
o := p.NamedObject("to"); WriteNumber(o);
Files.Register(f)
END SaveOptions;
PROCEDURE SetDefaultOptions*;
PROCEDURE InitPrintDlg*;
PROCEDURE SaveOptions*;
PROCEDURE Print*;
VAR t: Texts.Text; o: Dialogs.Object;
BEGIN
Texts.OpenWriter (w);
InitPar; Texts.WriteString(w, "QuickDraw * ");
IF On ("draft") THEN Texts.WriteString(w, "% ") END;
IF On ("alternate") THEN Texts.Write(w, OptionChar); Texts.WriteString(w, "a ") END;
IF On ("nopagenr") THEN Texts.Write(w, OptionChar); Texts.WriteString(w, "p n ") END;
IF On ("nopagenr1") THEN Texts.Write(w, OptionChar); Texts.WriteString(w, "p f ") END;
IF On ("Romannum") THEN Texts.Write(w, OptionChar); Texts.WriteString(w, "p r ") END;
o := p.NamedObject("tfirstpage"); t := o(DialogTexts.Item).GetText();
IF t.len > 0 THEN Texts.Write(w, OptionChar); Texts.WriteString(w, "p ");Texts.Save(t, 0, t.len, w.buf); Texts.WriteString(w, " ") END;
o := p.NamedObject("font"); t := o(DialogTexts.Item).GetText();
IF t.len > 0 THEN Texts.Write(w, OptionChar); Texts.WriteString(w, "f "); Texts.Save(t, 0, t.len, w.buf); Texts.Write(w, " ") END;
o := p.NamedObject("copies"); t := o(DialogTexts.Item).GetText();
IF t.len > 0 THEN Texts.Write(w, OptionChar); Texts.WriteString(w, "c "); Texts.Save(t, 0, t.len, w.buf); Texts.Write(w, " ") END;
IF On ("defhdr") THEN Texts.Write(w, OptionChar); Texts.WriteString(w, "h ") END;
IF On ("header") THEN
Texts.Write(w, OptionChar); Texts.WriteString(w, "h "); Save ("thdr"); Texts.Write(w, " ")
END;
IF On ("custom1") THEN
Texts.Write(w, OptionChar); Texts.WriteString(w, "m b ");
Save ("postxtleft"); Texts.Write(w, " "); Save ("postxtbottom"); Texts.Write(w, " ");
Save ("txtwidth"); Texts.Write(w, " "); Save ("txtheight"); Texts.Write(w, " ")
END;
IF On ("custom2") THEN
Texts.Write(w, OptionChar); Texts.WriteString(w, "m h "); Save ("poshdrleft"); Texts.Write(w, " ");
Save ("poshdrbottom"); Texts.Write(w, " "); Save ("hdrwidth"); Texts.Write(w, " ")
END;
IF On ("fromto") THEN
Texts.Write(w, OptionChar); Texts.WriteString(w, "s ");
o := p.NamedObject("from"); t := o(DialogTexts.Item).GetText(); IF t.len > 0 THEN Texts.Save(t, 0, t.len, w.buf) END;
Texts.Write(w, " ");
o := p.NamedObject("to"); t := o(DialogTexts.Item).GetText(); IF t.len > 0 THEN Texts.Save(t, 0, t.len, w.buf) END
END;
Call ("Edit.Print")
END Print;
Syntax10.Scn.Fnt
Syntax10b.Scn.Fnt
FoldElems
PROCEDURE Search*;
VAR res: INTEGER; t: Texts.Text; o: Dialogs.Object;
BEGIN
p := Dialogs.cmdPanel; o := p.NamedObject("search"); t := o(DialogTexts.Item).GetText();
o(DialogTexts.Item).SetSelection(0, t.len);
IF On ("folds") THEN Oberon.Call("FoldElems.Search", Oberon.Par, FALSE, res)
ELSE Oberon.Call("Edit.Search", Oberon.Par, FALSE, res)
END;
o(DialogTexts.Item).RemoveSelection;
doSearch := FALSE
END Search;
PROCEDURE Replace*;
VAR res: INTEGER; t: Texts.Text; o: Dialogs.Object; f: TextFrames.Frame;
BEGIN
f := XIn.FocusFrame(TRUE);
IF f # NIL THEN
p := Dialogs.cmdPanel;
IF doSearch THEN
doSearch := FALSE;
o := p.NamedObject("search"); t := o(DialogTexts.Item).GetText();
o(DialogTexts.Item).SetSelection(0, t.len);
IF On ("folds") THEN Oberon.Call("FoldElems.Search", Oberon.Par, FALSE, res)
ELSE Oberon.Call("Edit.Search", Oberon.Par, FALSE, res)
END;
o(DialogTexts.Item).RemoveSelection;
END;
o := p.NamedObject("repl"); t := o(DialogTexts.Item).GetText();
IF t.len = 0 THEN
Oberon.Call("Edit.ClearReplaceBuffer", Oberon.Par, FALSE, res)
ELSE
o(DialogTexts.Item).SetSelection(0, t.len)
END;
IF On ("all") THEN Oberon.Call("Edit.ReplaceAll", Oberon.Par, FALSE, res)
ELSE Oberon.Call("Edit.Replace", Oberon.Par, FALSE, res)
END;
o(DialogTexts.Item).RemoveSelection
END
END Replace;
PROCEDURE SearchReset*;
BEGIN doSearch := TRUE
END SearchReset;
Syntax10.Scn.Fnt
FoldElems
PROCEDURE GetType*;
VAR t: Texts.Text; beg, end, time: LONGINT; r: Texts.Reader; type: Types.Type;
s: ARRAY 64 OF CHAR; i, j: INTEGER;
BEGIN
Oberon.GetSelection(t, beg, end, time);
IF time >= 0 THEN
Texts.OpenReader(r, t, beg); Texts.ReadElem(r);
IF ~r.eot THEN
type := Types.TypeOf(r.elem);
p := Dialogs.cmdPanel; o := p.NamedObject("type");
i := 0; WHILE type.module.name[i] # 0X DO s[i] := type.module.name[i]; INC(i) END; s[i] := "."; INC(i);
j := i; WHILE type.name[j - i] # 0X DO s[j] := type.name[j - i]; INC(j) END; s[j] := 0X;
o(DialogStaticTexts.Item).SetString(s)
END
END
END GetType;
Syntax10.Scn.Fnt
Syntax10b.Scn.Fnt
FoldElems
PROCEDURE AddVar* (n: ARRAY OF CHAR; value: LONGREAL);
VAR var: Var; txt: Texts.Text;
BEGIN
NEW(var); var.next := vars; vars := var; COPY(n, var.name); var.value := value;
p := Dialogs.cmdPanel; o := p.NamedObject("gset"); txt := o(DialogComboBoxes.Item).menu;
Texts.WriteString(w, n); Texts.Write(w, 0DX);
Texts.Append(txt, w.buf);
END AddVar;
PROCEDURE ShowNumber*;
VAR r: Texts.Reader; txt: Texts.Text; i: INTEGER; str: ARRAY 32 OF CHAR;
s: Texts.Scanner;
PROCEDURE WrHex (n: LONGREAL);
VAR x, y: LONGINT; i: INTEGER;
a: ARRAY 10 OF CHAR;
BEGIN x := ENTIER(n + eps0);
i := 0; Texts.Write(w, " ");
REPEAT y := x MOD 10H;
IF y < 10 THEN a[i] := CHR(y + 30H) ELSE a[i] := CHR(y + 37H) END;
x := x DIV 10H; INC(i)
UNTIL i = 8;
REPEAT DEC(i) UNTIL (i = 0) OR (a[i] # "0");
IF a[i] >= "A" THEN Texts.Write(w, "0") END;
WHILE i >= 0 DO Texts.Write(w, a[i]); DEC(i) END;
Texts.Write(w, "H")
END WrHex;
PROCEDURE WrBin (n: LONGREAL);
VAR x: LONGINT; i: INTEGER;
a: ARRAY 30 OF CHAR;
BEGIN x := ENTIER(n + eps0);
i := 0; Texts.Write(w, " ");
REPEAT
a[i] := CHR(ORD("0") + (x MOD 2));
x := x DIV 2; INC(i)
UNTIL i = 28;
REPEAT DEC(i) UNTIL (i = 0) OR (a[i] # "0");
WHILE i >= 0 DO Texts.Write(w, a[i]); DEC(i) END;
Texts.Write(w, "B")
END WrBin;
PROCEDURE WrOct (n: LONGREAL);
VAR x, y: LONGINT; i: INTEGER;
a: ARRAY 16 OF CHAR;
BEGIN x := ENTIER(n + eps0);
i := 0; Texts.Write(w, " ");
REPEAT y := x MOD 8;
a[i] := CHR(y + 30H);
x := x DIV 8; INC(i)
UNTIL i = 14;
REPEAT DEC(i) UNTIL (i = 0) OR (a[i] # "0");
WHILE i >= 0 DO Texts.Write(w, a[i]); DEC(i) END;
Texts.Write(w, "C")
END WrOct;
PROCEDURE WrInt (n: LONGREAL);
BEGIN Texts.Write(w, " "); Texts.WriteInt(w, ENTIER(n + eps0), 0) END WrInt;
PROCEDURE WrChar (n: LONGREAL);
VAR ch: CHAR;
PROCEDURE Ch (ch: CHAR);
BEGIN Texts.Write(w, ch) END Ch;
BEGIN ch := CHR(ENTIER(n + eps0));
IF (" " <= ch) & (ch < 7FX) OR (80X <= ch) & (ch < 0A0X) THEN Ch(" "); Ch(22X); Ch(ch); Ch(22X)
ELSE WrHex(ORD(ch))
END
END WrChar;
PROCEDURE WrReal (n: LONGREAL);
VAR x: LONGREAL;
BEGIN
IF (MIN(LONGINT) <= n) & (n <= MAX(LONGINT)) THEN
x := ABS(n - ENTIER(SHORT(n)));
IF x < eps THEN WrInt(n); RETURN END
END;
IF (MIN(REAL) <= n) & (n <= MAX(REAL)) THEN x := ABS(n - SHORT(n));
IF x < eps THEN
IF (-10000 < n) & (n < 10000) THEN Texts.WriteRealFix(w, SHORT(n + eps0), 0, 6)
ELSE Texts.WriteReal(w, SHORT(n + eps0), 14)
END;
RETURN
END
END;
Texts.WriteLongReal(w, n, 23)
END WrReal;
BEGIN
p := Dialogs.cmdPanel; IF p = NIL THEN RETURN END;
o := p.NamedObject("mode"); IF o = NIL THEN RETURN END;
txt := o(DialogComboBoxes.Item).GetTitle();
Texts.OpenScanner(s, txt, 0); Texts.Scan(s);
IF s.s = "hex" THEN WrHex(value)
ELSIF s.s = "bin" THEN WrBin(value)
ELSIF s.s = "oct" THEN WrOct(value)
ELSIF s.s = "dec" THEN WrInt(value)
ELSIF s.s = "char" THEN WrChar(value)
ELSE WrReal(value) END;
txt := TextFrames.Text(""); Texts.Append(txt, w.buf); Texts.OpenReader(r, txt, 0); i := 0;
REPEAT
Texts.Read(r, str[i]);
INC(i)
UNTIL r.eot;
str[i - 1] := 0X;
o := p.NamedObject("t1"); o(DialogStaticTexts.Item).SetString(str)
END ShowNumber;
PROCEDURE Clear*;
BEGIN
oldValue := 0; value := 0; commaPos := 10;
oldOp := "add";
newNumber := TRUE;
ShowNumber;
END Clear;
PROCEDURE Reset*;
VAR txt: Texts.Text;
BEGIN
Clear;
p := Dialogs.cmdPanel; IF p = NIL THEN RETURN END;
o := p.NamedObject("gset"); IF o = NIL THEN RETURN END;
txt := o(DialogComboBoxes.Item).menu; Texts.Delete(txt, 0, txt.len);
vars := NIL;
AddVar("pi", MathL.pi);
AddVar("e", MathL.e);
o := p.NamedObject("gset");
txt := TextFrames.Text(""); o(DialogComboBoxes.Item).SetTitle(txt)
END Reset;
PROCEDURE Num*;
VAR i, base: INTEGER; txt: Texts.Text; s: Texts.Scanner;
BEGIN
In.Open; In.Int(i);
p := Dialogs.cmdPanel; o := p.NamedObject("mode"); txt := o(DialogComboBoxes.Item).GetTitle();
Texts.OpenScanner(s, txt, 0); Texts.Scan(s);
IF s.s = "hex" THEN base := 16
ELSIF s.s = "bin" THEN base := 2
ELSIF s.s = "oct" THEN base := 8
ELSE base := 10 END;
IF newNumber THEN
newNumber := FALSE;
value := i
ELSIF commaPos > 1 THEN
value := base * value + i
ELSE
commaPos := commaPos / base;
value := value + commaPos * i
END;
ShowNumber
END Num;
PROCEDURE Comma*;
BEGIN commaPos := 1 END Comma;
PROCEDURE Op*;
PROCEDURE Invers(): BOOLEAN;
VAR o: Dialogs.Object;
BEGIN
o := p.NamedObject("inv");
RETURN o(DialogCheckBoxes.Item).on
END Invers;
PROCEDURE OpLocal(op: Operation);
BEGIN
IF op = "add" THEN value := oldValue + value; oldValue := value
ELSIF op = "sub" THEN value := oldValue - value; oldValue := value
ELSIF op = "mult" THEN value := oldValue * value; oldValue := value
ELSIF op = "div" THEN value := oldValue / value; oldValue := value
ELSIF op = "sign" THEN value := - value
ELSIF op = "oneDivX" THEN value := 1 / value
ELSIF op = "sqr" THEN IF ~Invers() THEN value := value * value ELSE value := MathL.sqrt(value) END
ELSIF op = "sin" THEN IF ~Invers() THEN value := MathL.sin(value) ELSE value := MoreMathL.arcsin(value) END
ELSIF op = "cos" THEN IF ~Invers() THEN value := MathL.cos(value) ELSE value := MoreMathL.arccos(value) END
ELSIF op = "tan" THEN IF ~Invers() THEN value := MoreMathL.tan(value) ELSE value := MathL.arctan(value) END
ELSIF op = "exp" THEN IF ~Invers() THEN value := MathL.exp(value) ELSE value := MathL.ln(value) END
ELSE Out.Ln; Out.String("unexpected operator: "); Out.String(op) END;
END OpLocal;
BEGIN
In.Open;
In.Name(op);
IF (op = "add") OR (op = "sub") OR (op = "mult") OR (op = "div") OR (op = "res") THEN
OpLocal(oldOp);
IF op # "=" THEN oldOp := op END
ELSE OpLocal(op) END;
commaPos := 10; newNumber := TRUE;
ShowNumber
END Op;
PROCEDURE SetVar*;
VAR txt: Texts.Text; r: Texts.Reader; i: INTEGER; var: Var;
BEGIN
p := Dialogs.cmdPanel; o := p.NamedObject("set"); txt := o(DialogTexts.Item).GetText();
NEW(var); var.next := NIL; var.value := value;
Texts.OpenReader(r, txt, 0); i := 0; Texts.Read(r, var.name[i]);
WHILE ~r.eot DO
INC(i);
Texts.Read(r, var.name[i])
END;
o := p.NamedObject("gset"); txt := o(DialogComboBoxes.Item).menu;
Texts.WriteString(w, var.name); Texts.Write(w, 0DX);
Texts.Append(txt, w.buf);
var.next := vars; vars := var
END SetVar;
PROCEDURE Variable*;
VAR txt: Texts.Text; cur: Var; s: ARRAY 32 OF CHAR; r: Texts.Reader; i: INTEGER;
BEGIN
p := Dialogs.cmdPanel; o := p.NamedObject("gset"); txt := o(DialogComboBoxes.Item).GetTitle();
Texts.OpenReader(r, txt, 0); i := 0; Texts.Read(r, s[i]);
WHILE ~r.eot & (s[i] # 0DX) DO
INC(i);
Texts.Read(r, s[i])
END;
s[i] := 0X;
cur := vars;
WHILE (cur # NIL) & (cur.name # s) DO cur := cur.next END;
IF (cur # NIL) & (cur.name = s) THEN value := cur.value; ShowNumber END
END Variable;
PROCEDURE InitCalc*;
VAR menu, title: Texts.Text;
BEGIN
Reset;
p := Dialogs.cmdPanel; o := p.NamedObject("mode"); menu := o(DialogComboBoxes.Item).menu;
Texts.WriteString(w, "dec"); Texts.Write(w, 0DX);
Texts.WriteString(w, "bin"); Texts.Write(w, 0DX);
Texts.WriteString(w, "oct"); Texts.Write(w, 0DX);
Texts.WriteString(w, "hex"); Texts.Write(w, 0DX);
Texts.WriteString(w, "real"); Texts.Write(w, 0DX);
Texts.WriteString(w, "char"); Texts.Write(w, 0DX);
Texts.Append(menu, w.buf);
title := TextFrames.Text(""); Texts.WriteString(w, "dec"); Texts.Append(title, w.buf);
o(DialogComboBoxes.Item).SetTitle(title)
END InitCalc;
MODULE MyUI;
(* Christoph Steindl 20 Dec 94 -
(* Folds.Compile XIn.Mod/s MoreMathL.Mod/s MyUI.Mod/s ~ *)
IMPORT Dialogs, Oberon, Texts, TextFrames, DialogCheckBoxes, DialogRadioButtons, DialogComboBoxes,
DialogTexts, In, Out, Compiler, Files, MenuViewers, Viewers, Display, StyleElems, ParcElems, Types,
DialogStaticTexts, MathL, MoreMathL, XIn;
Constants
Types
Global variables
PROCEDURE DoHALT*;
VAR elem: StyleElem;
BEGIN
elem := styleElems;
WHILE elem # NIL DO
Out.Ln; Out.String(elem.styleElem.name);
elem := elem.next
END;
HALT(90)
END DoHALT;
PROCEDURE InitPar;
BEGIN p := Dialogs.cmdPanel; NEW (par); par.text := TextFrames.Text("")
END InitPar;
PROCEDURE Call (s: ARRAY OF CHAR);
BEGIN Texts.Append (par.text, w.buf); par.frame := Oberon.Par.frame; par.vwr := Oberon.Par.vwr; Oberon.Call (s, par, FALSE, res)
END Call;
PROCEDURE StoreLog;
BEGIN newLog := TextFrames.Text(""); oldLog := Oberon.Log; Oberon.Log := newLog
END StoreLog;
PROCEDURE On (s: ARRAY OF CHAR): BOOLEAN;
VAR o: Dialogs.Object;
BEGIN
o := p.NamedObject (s);
WITH o: DialogRadioButtons.Item DO RETURN o.on
| o: DialogCheckBoxes.Item DO RETURN o.on
ELSE RETURN FALSE
END
END On;
PROCEDURE ChangeValue (s: ARRAY OF CHAR; on: BOOLEAN);
VAR o: Dialogs.Object;
BEGIN
o := p.NamedObject (s);
IF o # NIL THEN
WITH o: DialogRadioButtons.Item DO o.ChangeValue (on)
| o: DialogCheckBoxes.Item DO o.ChangeValue (on)
ELSE HALT (99)
END
END
END ChangeValue;
PROCEDURE Write (s: ARRAY OF CHAR);
BEGIN IF On (s) THEN Texts.WriteString (w, s) END
END Write;
PROCEDURE WriteDefault (s: ARRAY OF CHAR);
BEGIN IF On (s) THEN Texts.WriteString (w, "default") END
END WriteDefault;
PROCEDURE Scan (VAR s: Texts.Scanner; st: ARRAY OF CHAR);
BEGIN
Texts.OpenScanner (s, newLog, 0); Texts.Scan (s);
IF st = "int" THEN
WHILE (s.class # Texts.Int) & (~s.eot) DO Texts.Scan (s) END
ELSE
WHILE (~ s.eot) & (s.class # Texts.Name) & (s.s # st) DO Texts.Scan (s) END
END
END Scan;
PROCEDURE Delete (s: ARRAY OF CHAR; VAR txt: Texts.Text);
VAR o: Dialogs.Object;
BEGIN o := p.NamedObject (s); txt := o(DialogTexts.Item).GetText(); Texts.Delete (txt, 0, txt.len)
END Delete;
PROCEDURE Save (s: ARRAY OF CHAR);
VAR txt: Texts.Text; o: Dialogs.Object;
BEGIN o := p.NamedObject (s); txt := o(DialogTexts.Item).GetText(); Texts.Save (txt, 0, txt.len, w.buf)
END Save;
Commands for the dialogue Compiler.Dlg
(*TD PROCEDURE StoreSelection;
VAR t: Texts.Text; beg, end, time: LONGINT;
BEGIN
XIn.GetSelectionViewer(vwr, t, beg, end, time);
IF (vwr.dsc # NIL) & (vwr.dsc.next # NIL) & (vwr.dsc.next IS TextFrames.Frame) THEN
Out.String("$Storing selbeg and selend");
selbeg := vwr.dsc.next(TextFrames.Frame).selbeg;
selend := vwr.dsc.next(TextFrames.Frame).selend
END
END StoreSelection;
PROCEDURE RestoreSelection;
BEGIN
IF (vwr.dsc # NIL) & (vwr.dsc.next # NIL) & (vwr.dsc.next IS TextFrames.Frame) THEN
Out.String("$Restoring selbeg and selend");
vwr.dsc.next(TextFrames.Frame).selbeg := selbeg;
vwr.dsc.next(TextFrames.Frame).selend := selend;
vwr.dsc.next(TextFrames.Frame).hasSel := TRUE
END
END RestoreSelection;
PROCEDURE Adjust*;
BEGIN
InitPar; Texts.WriteString(w, "adjust "); Write ("block"); Write ("center"); Write ("left"); Write ("right");
Call ("Edit.Set");
END Adjust;
PROCEDURE GetAdjust*;
VAR s: Texts.Scanner;
BEGIN
InitPar; StoreLog; Texts.WriteString(w, "adjust"); Call ("Edit.Get");
IF res = 0 THEN
Scan (s, "adjust"); Texts.Scan(s); Texts.Scan(s); ChangeValue (s.s, TRUE)
END;
Oberon.Log := oldLog
END GetAdjust;
PROCEDURE Break*;
BEGIN InitPar; Texts.WriteString(w, "break "); Write ("before"); Write ("normal"); Call ("Edit.Set")
END Break;
PROCEDURE GetBreak*;
VAR s: Texts.Scanner;
BEGIN
InitPar; StoreLog; Texts.WriteString(w, "break"); Call ("Edit.Get");
IF res = 0 THEN
Scan (s, "break"); Texts.Scan(s); Texts.Scan(s); ChangeValue (s.s, TRUE)
END;
Oberon.Log := oldLog
END GetBreak;
PROCEDURE Columns*;
BEGIN
InitPar; Texts.WriteString(w, "columns ");
IF On ("one") THEN Texts.WriteString(w, "1") ELSIF On ("two") THEN Texts.WriteString(w, "2") END;
Call ("Edit.Set")
END Columns;
PROCEDURE GetColumns*;
VAR s: Texts.Scanner;
BEGIN
InitPar; StoreLog; Texts.WriteString(w, "columns"); Call("Edit.Get");
IF res = 0 THEN
Texts.OpenScanner(s, newLog, 0); Texts.Scan(s);
WHILE ~s.eot & (s.class # Texts.Int) DO Texts.Scan(s) END;
IF s.i = 1 THEN ChangeValue ("one", TRUE)
ELSIF s.i = 2 THEN ChangeValue ("two", TRUE)
END
END;
Oberon.Log := oldLog
END GetColumns;
PROCEDURE First*;
VAR number: INTEGER;
BEGIN
InitPar; Texts.WriteString(w, "first "); WriteDefault ("firstdefault");
IF On ("firstnumber") THEN In.Open; In.Int(number); Texts.WriteInt(w, number, 0) END;
Call ("Edit.Set")
END First;
PROCEDURE GetFirst*;
VAR s: Texts.Scanner; txt: Texts.Text;
BEGIN
InitPar; StoreLog; Texts.WriteString(w, "first"); Call("Edit.Get");
IF res = 0 THEN
Scan (s, "int"); Delete ("tfirstnumber", txt);
IF s.class = Texts.Int THEN
Texts.WriteInt(w, s.i, 0); Texts.Append(txt, w.buf); ChangeValue ("firstnumber", TRUE)
ELSE
ChangeValue ("firstnumber", FALSE); ChangeValue ("firstdefault", FALSE);
END
END;
Oberon.Log := oldLog
END GetFirst;
PROCEDURE FirstReset*;
BEGIN p := Dialogs.cmdPanel; ChangeValue ("firstnumber", FALSE)
END FirstReset;
PROCEDURE Grid*;
BEGIN
InitPar; Texts.WriteString(w, "grid ");
IF On ("grid") THEN Texts.WriteString(w, "on") ELSE Texts.WriteString(w, "off") END;
Call ("Edit.Set")
END Grid;
PROCEDURE GetGrid*;
VAR s: Texts.Scanner;
BEGIN
InitPar; StoreLog; Texts.WriteString(w, "grid");
Call ("Edit.Get");
IF res = 0 THEN
Texts.OpenScanner(s, newLog, 0); Texts.Scan(s);
WHILE ~s.eot & (s.s # "on") & (s.s # "off") DO Texts.Scan(s) END;
IF s.s = "on" THEN ChangeValue("grid", TRUE)
ELSE ChangeValue("grid", FALSE) END
END;
Oberon.Log := oldLog
END GetGrid;
PROCEDURE Lead*;
BEGIN
InitPar; Texts.WriteString(w, "lead "); WriteDefault ("leaddef");
IF On ("leadnumber") THEN Save ("tleadnumber") END;
Call ("Edit.Set")
END Lead;
PROCEDURE GetLead*;
VAR s: Texts.Scanner; txt: Texts.Text;
BEGIN
InitPar; StoreLog; Texts.WriteString(w, "lead"); Call ("Edit.Get");
IF res = 0 THEN
Scan (s, "int"); Delete ("tleadnumber", txt);
IF s.class = Texts.Int THEN
Texts.WriteInt(w, s.i, 0); Texts.Append(txt, w.buf); ChangeValue ("leadnumber", TRUE)
ELSE
ChangeValue ("leadnumber", FALSE); ChangeValue ("leaddef", FALSE)
END
END;
Oberon.Log := oldLog
END GetLead;
PROCEDURE LeadReset*;
BEGIN p := Dialogs.cmdPanel; ChangeValue ("leadnumber", FALSE);
END LeadReset;
PROCEDURE Left*;
VAR number: INTEGER;
BEGIN
InitPar; Texts.WriteString(w, "left "); WriteDefault ("leftmargindef");
IF On ("leftmargin") THEN In.Open; In.Int(number); Texts.WriteInt(w, number, 0) END;
Call ("Edit.Set")
END Left;
PROCEDURE GetLeft*;
VAR txt: Texts.Text; s: Texts.Scanner;
BEGIN
InitPar; StoreLog; Texts.WriteString(w, "left");
Call("Edit.Get");
IF res = 0 THEN
Scan (s, "int"); Delete ("tleftmargin", txt);
IF s.class = Texts.Int THEN
Texts.WriteInt(w, s.i, 0); Texts.Append(txt, w.buf); ChangeValue ("leftmargin", TRUE)
ELSE
ChangeValue ("leftmargin", FALSE); ChangeValue ("leftmargindef", FALSE)
END
END;
Oberon.Log := oldLog
END GetLeft;
PROCEDURE LeftReset*;
BEGIN p := Dialogs.cmdPanel; ChangeValue ("leftmargin", FALSE)
END LeftReset;
PROCEDURE Right*;
VAR number: INTEGER;
BEGIN
InitPar; Texts.WriteString(w, "right "); WriteDefault ("rightmargindef");
IF On ("rightmargin") THEN In.Open; In.Int(number); Texts.WriteInt(w, number, 0) END;
Call ("Edit.Set")
END Right;
PROCEDURE GetRight*;
VAR txt: Texts.Text; s: Texts.Scanner;
BEGIN
InitPar; StoreLog; Texts.WriteString(w, "right");
Call ("Edit.Get");
IF res = 0 THEN
Scan (s, "int"); Delete ("trightmargin", txt);
IF s.class = Texts.Int THEN
Texts.WriteInt(w, s.i, 0); Texts.Append(txt, w.buf); ChangeValue ("rightmargin", TRUE)
ELSE
ChangeValue ("rightmargin", FALSE); ChangeValue ("rightmargindef", FALSE);
END
END;
Oberon.Log := oldLog
END GetRight;
PROCEDURE RightReset*;
BEGIN p := Dialogs.cmdPanel; ChangeValue ("rightmargin", FALSE)
END RightReset;
PROCEDURE Line*;
BEGIN
InitPar; Texts.WriteString (w, "line "); WriteDefault ("linedef");
IF On ("linenumber") THEN Save ("tlinenumber") END;
Call("Edit.Set")
END Line;
PROCEDURE GetLine*;
VAR txt: Texts.Text; s: Texts.Scanner;
BEGIN
InitPar; StoreLog; Texts.WriteString(w, "line ");
Call("Edit.Get");
IF res = 0 THEN
Scan (s, "int"); Delete ("tlinenumber", txt);
IF s.class = Texts.Int THEN
Texts.WriteInt(w, s.i, 0); Texts.Append(txt, w.buf); ChangeValue ("linenumber", TRUE)
ELSE
ChangeValue ("linenumber", FALSE); ChangeValue ("linedef", FALSE)
END
END;
Oberon.Log := oldLog
END GetLine;
PROCEDURE LineReset*;
BEGIN p := Dialogs.cmdPanel; ChangeValue ("linenumber", FALSE)
END LineReset;
PROCEDURE Tabs*;
VAR number: INTEGER;
BEGIN
InitPar; Texts.WriteString(w, "tabs ");
IF On ("every") THEN
In.Open; In.Int(number); Texts.WriteString(w, "* "); Texts.WriteInt(w, number, 0);
ELSE
IF On ("enum") THEN
In.Open; In.Int(number);
REPEAT Texts.WriteInt(w, number, 0); Texts.Write(w, " "); In.Int(number) UNTIL ~In.Done;
Texts.WriteString(w, " ~")
END
END;
Call ("Edit.Set")
END Tabs;
PROCEDURE GetTabs*;
VAR txt: Texts.Text; s: Texts.Scanner; ch: CHAR; Star: BOOLEAN;
BEGIN
InitPar; StoreLog; Texts.WriteString(w, "tabs");
Call ("Edit.Get");
IF res = 0 THEN
Texts.OpenReader(s, newLog, 0); Texts.Read(s, ch);
WHILE ~s.eot & (ch # "*") DO Texts.Read(s, ch) END;
Star := ch = "*"; Scan (s, "int");
IF Star THEN Delete("tevery", txt) ELSE Delete("tenum", txt) END;
REPEAT
IF s.class = Texts.Int THEN Texts.WriteInt(w, s.i, 0); Texts.Write(w, " ") END; Texts.Scan(s)
UNTIL s.eot OR (s.class # Texts.Int);
Texts.Append(txt, w.buf);
IF Star THEN ChangeValue ("every", TRUE) ELSE ChangeValue ("enum", TRUE) END
END;
Oberon.Log := oldLog
END GetTabs;
PROCEDURE TabsReset1*;
BEGIN p := Dialogs.cmdPanel; ChangeValue("every", FALSE)
END TabsReset1;
PROCEDURE TabsReset2*;
BEGIN p := Dialogs.cmdPanel; ChangeValue("enum", FALSE)
END TabsReset2;
PROCEDURE Width*;
VAR number: INTEGER;
BEGIN
InitPar; Texts.WriteString(w, "width ");
IF On ("widthdef") THEN Texts.WriteString(w, "default") END;
IF On ("width") THEN In.Open; In.Int(number); Texts.WriteInt(w, number, 0) END;
Call("Edit.Set")
END Width;
PROCEDURE GetWidth*;
VAR txt: Texts.Text; s: Texts.Scanner;
BEGIN
InitPar; StoreLog; Texts.WriteString(w, "width");
Call ("Edit.Get");
IF res = 0 THEN
Scan (s, "int"); Delete ("twidth", txt);
IF s.class = Texts.Int THEN
Texts.WriteInt(w, s.i, 0); Texts.Append(txt, w.buf); ChangeValue ("width", TRUE)
ELSE
ChangeValue ("width", FALSE); ChangeValue ("widthdef", FALSE)
END
END;
Oberon.Log := oldLog
END GetWidth;
PROCEDURE WidthReset*;
BEGIN p := Dialogs.cmdPanel; ChangeValue("width", FALSE)
END WidthReset;
PROCEDURE ThisStyleElem (VAR n: ARRAY OF CHAR): StyleElems.Parc;
VAR prev, next: StyleElem; new: StyleElems.Parc;
BEGIN
next := styleElems; prev := styleElems;
WHILE (next # NIL) & (next.styleElem.name # n) DO
prev := next; next := next.next
END;
IF next # NIL THEN
NEW(new); StyleElems.Copy(next.styleElem, new);
(* IF prev = next THEN styleElems := next.next ELSE prev.next := next.next END*)
END;
RETURN new
END ThisStyleElem;
PROCEDURE Style*;
VAR t, title: Texts.Text; beg, end, time: LONGINT; r: Texts.Reader; elem: Texts.Elem;
s: Texts.Scanner; styleElem, newElem: StyleElems.Parc; f: TextFrames.Frame;
PROCEDURE Replace (VAR t: Texts.Text; VAR r: Texts.Reader; styleElem: StyleElems.Parc);
BEGIN
Texts.Delete(t, Texts.Pos(r) - 1, Texts.Pos(r));
Texts.WriteElem(w, styleElem);
Texts.Insert(t, Texts.Pos(r) - 1, w.buf);
END Replace;
BEGIN
Oberon.GetSelection(t, beg, end, time);
f := XIn.FocusFrame(TRUE);
InitPar;
o := p.NamedObject("styles"); title := o(DialogComboBoxes.Item).GetTitle();
Texts.OpenScanner(s, title, 0); Texts.Scan(s);
IF time >= 0 THEN
Texts.OpenReader(r, t, beg); Texts.ReadElem(r);
IF (s.class IN {Texts.Name, Texts.String}) & ~r.eot THEN
elem := r.elem;
WITH elem: StyleElems.Parc DO
styleElem := ThisStyleElem(s.s);
IF styleElem = NIL THEN
Texts.WriteString(w, s.s); Call("StyleElems.Rename")
ELSE
Replace(t, r, styleElem)
END;
| elem: TextFrames.Parc DO
styleElem := ThisStyleElem(s.s);
IF styleElem = NIL THEN
NEW(styleElem); ParcElems.CopyParc(elem, styleElem);
styleElem.handle := StyleElems.Handle; COPY(s.s, styleElem.name);
END;
Replace(t, r, styleElem)
ELSE
END
END;
ELSE (* insert a style elem of the selected type at the caret position *)
IF (s.class IN {Texts.Name, Texts.String}) & (f # NIL) THEN
styleElem := ThisStyleElem(s.s); NEW(newElem);
StyleElems.Copy(styleElem, newElem);
Texts.WriteElem(w, newElem);
Texts.Insert(f.text, f.carloc.pos, w.buf)
END
END
END Style;
PROCEDURE GetStyles*;
VAR t, t2, t3, menu: Texts.Text; beg, end, time: LONGINT;r: Texts.Reader;
PROCEDURE AddStyles (t: Texts.Text);
VAR elem, next: StyleElem;
BEGIN
Texts.OpenReader(r, t, 0); Texts.ReadElem(r);
WHILE ~r.eot DO
IF r.elem IS StyleElems.Parc THEN
next := styleElems;
WHILE (next # NIL) & (next.styleElem.name # r.elem(StyleElems.Parc).name) DO
next := next.next
END;
IF next = NIL THEN (* not yet contained => insert *)
Texts.WriteString(w, r.elem(StyleElems.Parc).name); Texts.Write(w, 0DX);
NEW(elem); elem.styleElem := r.elem(StyleElems.Parc);
elem.next := styleElems; styleElems := elem
END
END;
Texts.ReadElem(r)
END
END AddStyles;
BEGIN
Oberon.GetSelection(t, beg, end, time);
IF time >= 0 THEN
p := Dialogs.cmdPanel; o := p.NamedObject ("styles");
menu := o(DialogComboBoxes.Item).menu; Texts.Delete(menu, 0, menu.len);
Texts.OpenReader(r, t, beg); Texts.ReadElem(r);
IF ~r.eot & (Texts.Pos(r) <= end) THEN
IF r.elem IS StyleElems.Parc THEN
t2 := o(DialogComboBoxes.Item).GetTitle(); Texts.Delete(t2, 0, t2.len);
Texts.WriteString(w, r.elem(StyleElems.Parc).name); Texts.Append(t2, w.buf);
Out.Ln; Out.String("Setting title to: "); Out.String(r.elem(StyleElems.Parc).name);
END
END;
styleElems := NIL; (* remember the styleElems in the text with the selection and in Styles.Text *)
AddStyles(t);
t := TextFrames.Text(""); Texts.Open(t, "Styles.Text"); AddStyles(t);
Texts.Append(menu, w.buf)
END
END GetStyles;
PROCEDURE GetAll*;
BEGIN
GetAdjust; GetBreak; GetColumns; GetFirst; GetGrid; GetLeft; GetRight;
GetWidth; GetTabs; GetLead; GetLine; GetStyles
END GetAll;
Commands for the dialogue Print.Dlg
Commands for the dialogue Search.Dlg
Commands for the dialogue Inspector.Dlg
Commands for the dialogue Calc.Dlg
BEGIN
doSearch := TRUE; Texts.OpenWriter (w);
Reset
END MyUI.Unload MyUI.DoHALT
Dialog.Open Insert.Dlg
Dialog.Open Compiler.Dlg
Dialog.Open GetSet.Dlg
Dialog.Open Print.Dlg
Dialog.Open Search.Dlg
Dialog.Open Inspector.Dlg
Dialog.Open Calc.Dlg
AsciiCoder.CodeFiles % MyUI.Mod MoreMathL.Mod XIn.Mod Insert.Dlg Compiler.Dlg
GetSet.Dlg Print.Dlg Search.Dlg Inspector.Dlg Calc.Dlg ~